/**
 * Created by gaolk on 2015/6/8.
 */
require.config({
    baseUrl: '/js/lib',
    urlArgs: "bust=" +  (new Date()).getTime(),
    paths:{
        jquery: 'jquery183',
        check:  'Checkform',
        alert:  'Open_Alert',
        userscroll:'jquery.tinyscrollbar.min',
        index:'/js/module/index',
        userReg:'/js/module/reg',
        getUserList:'getUserlist',
        code:'/editor/plugins/code/prettify',
        talk:'/js/module/talk'
    },
    shim:{
        'check': ['jquery'],
        'userscroll': ['jquery']

    }
});
require(['jquery','index','getUserList','code','talk','alert'],function($,Index,getuser,code,talk,alert){
     $(function(){
         Index.IndexAction();//初始化
         getuser.GetUser();//获取用户列表
         prettyPrint();
         talk.GetTalk($('.user-talk-enter').attr('data-articleid'));

         $('.user-talk-enter #code-img').click(function(){
             $(this).attr('src','/refresh?v='+Math.random());
         });
         $('[name=code-value]').focus(function(){
             $('.user-talk-enter #code-img').click();
         })
         $('#user-talk-button').click(function(){
             var value=$('#talk-content').val();
             var code=$('[name=code-value]').val();
             if(value!=''){
                 $.ajax({
                     type: "POST",
                     url: "/talkenter",
                     data: {content:value,title:$('.article-title').text(),id:$('.user-talk-enter').attr('data-articleid'),code:code},
                     dataType:'json',
                     success: function(msg){
                         if(msg.success==1){
                             alert.Message(400,'提示信息','恭喜发布评论成功',2000,0,function(){
                                  window.location.reload();
                             });
                         }else{
                             alert.Message(400,'提示信息',msg.text,2000,1);
                         }
                     }
                 })
             }
         })
     });

  });